package demo04;

import java.util.ArrayList;

public class work4 {
	public static void main(String[] args) {
		ArrayList<Integer> list=new ArrayList<Integer>();
		for(int i=1;i<=1000;i++){
			if(zhiShu(i)&&huiWenShu(i)){
				list.add(i);
			}
		}
		shuChu(list);
	}

	private static void shuChu(ArrayList<Integer> list) {
		String str="";
		int count=0;
		for(int i=0;i<list.size();i++){
			str=str+list.get(i)+" ";
			count++;
			if(count==10||i==list.size()-1){
				System.out.println(str);
				count=0;
				str="";
			}
			
		}
		
	}

	private static boolean huiWenShu(int i) {
		if(i/100==i%10){
			return true;
		}
		else if(i<100&&i/10==i%10){
			return true;
		}
		else if(i<10&&i!=1){
			return true;
		}
		else{
			return false;
		}
	}

	private static boolean zhiShu(int i) {
		int panDuan=0;
		for (int j=2;j<=i/2;j++){
			if(i%j==0){
				panDuan=1;
			}
		}
		if(panDuan==1){
			return false;
		}
		else{
			return true;
		}
		
	}
}
